package bluejack.text;

/**
 * 关于文本处理的静态方法
 * @author BlueJack
 */

class TextUtil 
{

	//是否合法的Email地址
	static public function isValidEmail( str : String ) : Bool {
		var reg:EReg = ~/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z][A-Z][A-Z]?/i;
		return reg.match( str );
	}
	
	//是否中文字符
	static public function isChineseCharacter(str:String):Bool {
		var reg:EReg = ~/[\u4e00-\u9fa5]/;
		return reg.match(str);
	}
	
	//删除空白行
	static public function removeBlankLine(str:String):String {
		var reg:EReg = ~/\n\s*\r/g;
		return reg.replace(str, "");
	}

	//删除所有换行
	static public function removeBR(str:String):String {
		var reg:EReg = ~/\r|\n|<br>/g;
		return reg.replace(str, "");
	}
	
	//删除行首行尾空白字符
	static public function trim(str:String):String {
		var reg:EReg = ~/(^\s*)|(\s*$)/g;
		return reg.replace(str, "");
	}
}